<template>
  <div class="page-box h100 display-flex czbj">
    <p class="title-label mb10">{{jdsfdfs}}--店铺管理</p>
    <div>
      
    </div>
    <div>
      <n-button type="info" @click="hf('adddianpu')"> 添加店铺 </n-button>
    </div>
    <n-table :single-line="false" class="mt20">
      <thead>
        <tr>
          <th>店铺id</th>
          <th>店铺名称</th>
          <th>店铺地址</th>
          <!-- <th>状态</th> -->
        <th>门店认证状态</th> 
          <th>操作</th>
        </tr>
      </thead>
      <tbody>
        <tr v-for="sd in shopInfos">
          <td>{{ sd.shopId }}</td>
          <td>{{ sd.shopName }}</td>
          <td>
             <span v-if="sd.businessAddress">
              {{ sd.businessAddress.ssdfda }}
             {{ sd.businessAddress.ssdfdb }}
             {{ sd.businessAddress.ssdfdc }} 
             {{ sd.businessAddress.address }}
             </span>
             <span v-else>{{ sd.address }}</span>
            </td>
          <!-- <td>
            {{ jzxcsdfd(sd.shopStatus) }}
          </td> -->
         <td>
           <div class="display-flex" v-if="sd.shopInfoStatus"> 
            {{ jzxcsdfdb(sd.shopInfoStatus) }}
            <div class="" v-if="sd.shopInfoStatus=='02'">
              <!-- <i class="iconfont dx-help ml10"></i> -->
            </div>
           </div>
           <div v-else class="ls sz">

            <n-button type="info" quaternary @click="initsd"  :loading="dsfdsfrttrt">
              {{ sd.isdrt }} <span >点击刷新状态</span>
                </n-button>

           
          
          </div>
        </td> 


          <td v-if="!sd.isdrt" width="160">
            <n-button type="info" quaternary @click="hf('meirongbjdp', sd)"> 编辑 </n-button>
            <n-button type="error" quaternary @click="shanchuser(sd)"> 删除 </n-button>

            <!-- <n-button type="info" quaternary @click="addsjsderr(sd)"> 添加收款账号 </n-button>
           -->
          </td>

        </tr>

      </tbody>
    </n-table>
    <div class="mt20 z9 fz12">
      
      温馨提示：门店认证状态 <br>
       待确认:系统识别门店基础信息存疑，需确认<br>
  审核中:信息提交后进入审核流程<br>
待优化:建议修改门店基础信息<br>
已认证:完成认证后可参与营销、权益、卡、券等相关活动<br>
暂停营业:商家门店已暂停营业，不参与营销、权益、卡、券等相关活动
    </div>
  </div>
</template>
<script lang='ts' setup>
import { ref } from 'vue'
import { dxget, hf, dialog, dxpost } from "../../util/index";
const shopInfos = ref([])
const dsfdsfrttrt = ref(false)
const jdsfdfs = localStorage.sjmcsee
if(!localStorage.app_auth_token){
  hf('shangjiagl')
}
const zhjhsd = [
  { label: '已认证', value: '01' },
  { label: '待优化', value: '02' },
  { label: '审核中', value: '03' },
  { label: '未知', value: '99' },
]
const jnxdfd = [
  { label: '正常', value: '01' },
  { label: '冻结', value: '03' },
]
const jzxcsdfd = (valus) => {
  return jnxdfd.filter(a => a.value == valus)[0].label
}
const jzxcsdfdb = (valus) => {
  return zhjhsd.filter(a => a.value == valus)[0].label
}
const initsd = async () => {
  dsfdsfrttrt.value = true
  const { data } = await dxget('meirong/wantu/getshopquery')
  shopInfos.value = data.shopInfos
  try{
    const hnxdr =  JSON.parse(localStorage.dphcser)
    let jnxcdf = true
    shopInfos.value.map(a=>{
      if(a.shopName==hnxdr.shopName){
        localStorage.dphcser = null
        jnxcdf = false
      }
    })
    if(localStorage.dphcser&&localStorage.dphcser!='null'){
      shopInfos.value.push(hnxdr)
    }
    
  }catch(e){

  }
  dsfdsfrttrt.value = false
}
initsd()
const shanchuser = async (data) => {
  const res = await dialog("确认删除吗？");
  if (res == 1) {
    //等于1为确认删除了
    const ret = await dxpost('meirong/wantu/sanchudp',{shopId:data.shopId})
    window.$message.success('删除成功！')
    initsd()
  }
}
const addsjsderr =async (sd)=>{
  const {data} = await dxget('meirong/wantu/receiptaccountsave',{
    shop_id:sd.shopId,
    receipt_account_id:'2088702200202803'
  })
  console.log(data);
}
</script>
<style scoped></style>